perm filename LOTS.82[206,JMC] blob sn#679460 filedate 1982-10-01 generic text, type C, neo UTF8
COMMENT āŠ—   VALID 00002 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	\magnify{1200}
C00012 ENDMK
CāŠ—;
\magnify{1200}
\newfont cmb12 \is \title
\def\.#1{\hbox{\tt #1}}
\ctrline{\:\title Using MacLisp at Lots}
\vskip 10pt
\def\section#1{\par\penalty-50\vskip 8pt plus 4pt minus 4pt
	\hbox{\bf #1}\penalty10000\vskip 6pt plus 3pt minus 3pt}

\section{Opening a LOTS account}

We will be using the new LOTS computer, called LOTSB, in CS206 this quarter.
LOTSB terminals are located in the studio of the CERAS building.  If you have
never used LOTS before, you should read the short ``Introduction to LOTS''
available at CERAS.  Following the instructions there, open your account on
LOTSB.  If you need help, ask a consultant there or anyone who seems to know
what they're doing.

\section{How to begin}

LOTS runs the standard MacLisp for TOPS-20.  It can be run by typing \.{LISP}
or \.{MACLISP} to the LOTS monitor.  LISP will come back and type \.{Alloc?}
asking you if you want to change the allocation of memory areas.  Assuming you
don't, just type \.{N}, LISP will print a \.{*} and you are ready to go.

\section{Evaluating, errors, debugging}

As with other LISP interpreters the top level is a read-eval-print loop.  Type
in an S-expression and LISP returns its value.  MacLisp ordinarily does not
distinguish between upper and lower case letters.  Its values are normally
printed in upper case. Thus if you type in \.{(quote a)}, the value returned
will be \.{A}.  Error messages and other comments generated by the system are
prefaced with a semi-colon.  When an error is detected MACLISP prints a message
saying what it thinks is wrong, and goes into a ``break-loop'' allowing you to
examine the environment in which the error occurred.  (This feature is
documented in the MACLISP reference manual.)  To return to the top level type
\.{<control>G}. (Hold down the \.{<control>} key while typing ``\.{G}''.)
Sometimes the error message is sufficient to tell you what is wrong.  Often it
is not.  There are some useful debugging aids in LISP.  In particular the TRACE
and STEP facilities are useful.  If you \.{(TRACE FOO)} and then evaluate
\.{(FOO arg1 arg2 ...\ argn)}, each time \.{FOO} is called the values of its
arguments are printed and each time it is exited, the result is printed.  To
turn off the trace type \.{(UNTRACE FOO)}.

\section{Pretty-printing}

If you have defined a function (using \.{DEFUN} for example) then you can
``pretty-print'' it using \.{GRINDEF}.  A pretty-printer prints the function
nicely indented to exhibit the structure of the program.

\section{Simple file I/O}

In addition to printing definitions on a terminal you will want to read them
from a file and write them onto a file.  There is a function called \.{LOAD},
which loads definitions from a file.  It expects the file to contain a sequence
of S-expressions.  Type \.{(LOAD filespec)}, with the filespec quoted, as in
\.{(LOAD 'FOO)} to load functions from the file \.{FOO.LSP}.  To load a file
from some other directory, say \.{<u.user>} type
\.{(LOAD '((|u.user|) FOO LSP))}.  This loads from \.{<u.user>foo.lsp}.

Good documentation on file I/O is in the file \.{<MACLISP>NEWIO.DOC}.  Most of
this documentation refers to the \.{ITS} operating system, which uses a
different syntax for filenames. For example, on TOPS-20 we must use
\.{|DEVICE:<DIR>NAME.EXT|} where they have \.{|DEVICE: DIR; NAME EXT|}.

\section{Editing}

LEDIT is an interface between MACLISP and EMACS which enables you to use EMACS
to edit your LISP code.  LEDIT is documented in the file \.{INFO:LEDIT.INFO},
which is under the node EMACS in the INFO tree.  The simplest use of LEDIT is as
follows:

Assume you are in LISP and have loaded some functions from a file \.{FOO.LSP}
and found a bug.

From LISP, type \.{(ledit)}.  This will create an EMACS as a subfork of LISP.
When in EMACS, load the library \.{LEDIT} (this can be done automatically for
you, see the INFO file).  Then visit \.{FOO.LSP} and fix the bug.  Leave the
cursor inside the definition of the buggy function and type \.{C-X z}.  This will
save the file and exit back to LISP, which will then read in the new definition
of the buggy function.

\section{Exiting}

To exit LISP type \.{(QUIT)}, \.{<control>C}, or \.{<control>Z}.

\section{Suggestions for Homework Preparation}

Some of the homework for CS206 involves writing LISP programs to compute some
given recursive functions.  You are expected to debug the programs and then turn
in the following things for each program:

\item{1.} The internal form of the program.
\item{2.} The corresponding external form recursive definition.
\item{3.} A description of how the program works and why.
\item{4.} Output from test runs on a variety of input.

\noindent This collection of data can be put together in many ways.  The
following procedure is just one possibility.

\item{1.}  Using some editor available at LOTS create a file and type in
the programs you wish to test.  This allows you to use the editor to
correct typos.  Parenthesis matching is essential here, so check it
carefully.

\item{2.}  When you think your programs are correctly written run LISP and read
in the file (using \.{LOAD}).  Now try your functions on some trivial cases.  If
you discover some bugs fix them using the LISP-EMACS Interface (LEDIT) .
Alternately you can rewrite the entire file if not too large.  Now test them on
non trivial data until you are convinced they are correct.

\item{3.} To get output from sample runs the \.{PHOTO} program is useful.
\.{PHOTO} creates a file in which it keeps a log of what you type to
the terminal and what it types back.  Type \.{HELP PHOTO} to the monitor
to find out how to use it.

\item{4.} Finally you can edit the file containing the pretty printed versions
of your programs and add external form definitions and documentation
for each program, list this and the \.{PHOTO} file and turn them in.

\vfill\end